package com.itboye.ihomebank.presenter;

import com.itboye.ihomebank.base.BasePresenter;
import com.itboye.ihomebank.base.ICompleteListener;
import com.itboye.ihomebank.bean.HouseBean;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.interfaces.KeyTwoInterface;
import com.itboye.ihomebank.responsitory.KeyTwoRepository;

import java.util.Observer;

/**
 * 白马锁钥匙接口类
 */
public class KeyTwoPresenter extends BasePresenter implements KeyTwoInterface<HouseBean> {
    // 注册
    public static final String register_success = KeyTwoPresenter.class.getName()+ "_Rregister_success";// 由此判断请求的接口
    public static final String register_fail = KeyTwoPresenter.class.getName()+ "_Register_fail";
    // 绑定管理员
    public static final String addMain_success = KeyTwoPresenter.class.getName()+ "_AddMain_success";
    public static final String addMain_fail = KeyTwoPresenter.class.getName()+ "_AddMain_fail";
    // 开锁记录
    public static final String kaisuo_success = KeyTwoPresenter.class.getName()+ "_kaisuo_success";
    public static final String kaisuo_fail = KeyTwoPresenter.class.getName() + "_kaisuo_fail";
    // 修改钥匙有效期
    public static final String qixian_success = KeyTwoPresenter.class.getName()+ "_qixian_success";
    public static final String qixian_fail = KeyTwoPresenter.class.getName()+ "_qixian_fail";
    // 冻结钥匙
    public static final String dongjie_success = KeyTwoPresenter.class.getName()+ "_dongjie_success";
    public static final String dongjie_fail = KeyTwoPresenter.class.getName()+ "_dongjie_fail";
    // 解冻钥匙
    public static final String jiedong_success = KeyTwoPresenter.class.getName()+ "_jiedong_success";
    public static final String jiedong_fail = KeyTwoPresenter.class.getName()+ "_jiedong_fail";
    // 重置键盘密码
    public static final String jianpanPass_success = KeyTwoPresenter.class.getName() + "_jianpanPass_success";
    public static final String jianpanPass_fail = KeyTwoPresenter.class.getName() + "_jianpanPass_fail";
    // 发送键盘密码
    public static final String sendJianPanPass_success = KeyTwoPresenter.class.getName() + "_sendJianPanPass_success";
    public static final String sendJianPanPass_fail = KeyTwoPresenter.class.getName() + "_sendJianPanPass_fail";
    // 判断是否注册白马锁
    public static final String isregSitri_success = KeyTwoPresenter.class.getName() + "_isregSitri_success";
    public static final String isregSitri_fail = KeyTwoPresenter.class.getName() + "_isregSitri_fail";
    // 注册白马锁
    public static final String regSitri_success = KeyTwoPresenter.class.getName() + "_regSitri_success";
    public static final String regSitri_fail = KeyTwoPresenter.class.getName() + "_regSitri_fail";
    // 锁初始化-白马锁（绑定到服务器）
    public static final String initSitri_success = KeyTwoPresenter.class.getName()
            + "_initSitri_success";
    public static final String initSitri_fail = KeyTwoPresenter.class.getName() + "_initSitri_fail";
    // 获取租户信息--发送钥匙的时候用到。当该用户的这把锁绑定了房源，获取到该客户的信息
    public static final String rentInfo_success = KeyTwoPresenter.class.getName() + "_rentInfo_success";
    public static final String rentInfo_fail = KeyTwoPresenter.class.getName() + "_rentInfo_fail";
    //  上传锁电量
    public static final String setPower_success = KeyTwoPresenter.class.getName() + "_setPower_success";
    public static final String setPower_fail = KeyTwoPresenter.class.getName() + "_setPower_fail";
    // 上传开锁记录
    public static final String uploadjilu_success = KeyTwoPresenter.class.getName() + "_uploadjilu_success";
    public static final String uploadjilu_fail = KeyTwoPresenter.class.getName() + "_uploadjilu_fail";
    public static final String uploadjilu_two_success = KeyTwoPresenter.class.getName() + "_uploadjilu_two_success";
    public static final String uploadjilu_two_fail = KeyTwoPresenter.class.getName() + "_uploadjilu_two_fail";
    // 查询钥匙
    public static final String myKey_success = KeyTwoPresenter.class.getName() + "_MyKey_success";
    public static final String myKey_fail = KeyTwoPresenter.class.getName() + "_MyKey_fail";
    // 修改钥匙别名
    public static final String updateKey_success = KeyTwoPresenter.class.getName() + "_UpdateKey_success";
    public static final String updateKey_fail = KeyTwoPresenter.class.getName() + "_UpdateKey_fail";
    // 发送钥匙
    public static final String sendKey_success = KeyTwoPresenter.class.getName() + "_sendKey_success";
    public static final String sendKey_fail = KeyTwoPresenter.class.getName() + "_sendKey_fail";
    // 锁的钥匙列表
    public static final String keyOfLock_success = KeyTwoPresenter.class.getName() + "_keyOfLock_success";
    public static final String keyOfLock_fail = KeyTwoPresenter.class.getName() + "_keyOfLock_fail";
    // 键盘密码记录
    public static final String pass_jilu_success = KeyTwoPresenter.class.getName() + "_pass_jilu_success";
    public static final String pass_jilu_fail = KeyTwoPresenter.class.getName() + "_pass_jilu_fail";
    // 解除绑定
    public static final String unbindAdmin_success = KeyTwoPresenter.class.getName() +"_unbindAdmin_success";
    public static final String unbindAdmin_fail = KeyTwoPresenter.class.getName() +"_unbindAdmin_fail";
    // 消息推送
    public static final String tuisong_success = KeyTwoPresenter.class.getName() +"_tuisong_success";
    public static final String tuisong_fail = KeyTwoPresenter.class.getName() +"_tuisong_fail";
    // 密码添加前置
    public static final String qianzhi_success = KeyTwoPresenter.class.getName() +"_qianzhi_success";
    public static final String qianzhi_fail = KeyTwoPresenter.class.getName() +"_qianzhi_fail";
    // 密码删除回调
    public static final String delete_pass_success = KeyTwoPresenter.class.getName() +"_delete_pass_success";
    public static final String delete_pass_fail = KeyTwoPresenter.class.getName() +"_delete_pass_fail";
    // 密码修改回调
    public static final String modify_pass_success = KeyTwoPresenter.class.getName() +"_modify_pass_success";
    public static final String modify_pass_fail = KeyTwoPresenter.class.getName() +"_modify_pass_fail";
    // 密码添加回调
    public static final String add_pass_success = KeyTwoPresenter.class.getName() +"_add_pass_success";
    public static final String add_pass_fail = KeyTwoPresenter.class.getName() +"_add_pass_fail";
    // 密码别名
    public static final String modify_alias_success = KeyTwoPresenter.class.getName() +"_modify_alias_success";
    public static final String modify_alias_fail = KeyTwoPresenter.class.getName() +"_modify_alias_fail";
    // 钥匙别名
    public static final String key_alias_success = KeyTwoPresenter.class.getName() +"_key_alias_success";
    public static final String key_alias_fail = KeyTwoPresenter.class.getName() +"_key_alias_fail";
    public KeyTwoPresenter(Observer observer) {
        super(observer);
    }

    @Override
    public void onRegister(String uid) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(register_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(register_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);

                    }
                });
        user.onRegister(uid);
    }

    @Override
    public void onAddMain(String uid, String lock_type, String lockName,
                          String lockAlias, String lockMac, String lockKey,
                          String lockFlagPos, String aesKeyStr, String version,
                          String adminPwd, String noKeyPwd, String deletePwd, String pwdInfo, String timestamp, String specialValue) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(addMain_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(addMain_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);

                    }
                });
        key.onAddMain(uid, lock_type, lockName, lockAlias, lockMac, lockKey,
                lockFlagPos, aesKeyStr, version, adminPwd, noKeyPwd, deletePwd, pwdInfo, timestamp, specialValue);

    }

    /**
     * 开锁记录
     */
    @Override
    public void onKaiSuoJiLu(String uid, String lock_id, String current_page,
                             String per_page) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(kaisuo_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(kaisuo_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);

                    }
                });
        key.onKaiSuoJiLu(uid, lock_id, current_page, per_page);
    }

    /**
     * 修改钥匙有效期
     */
    @Override
    public void onYouXiaoQi(String uid, String key_id, String lock_id, String start, String end) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(qixian_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(qixian_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);

                    }
                });
        key.onYouXiaoQi(uid, key_id, lock_id, start, end);
    }

    /**
     * 冻结钥匙
     */
    @Override
    public void onDongJie(String uid, String to_uid, String lock_id,
                          String key_id) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(dongjie_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(dongjie_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);

                    }
                });
        key.onDongJie(uid, to_uid, lock_id, key_id);
    }

    /**
     * 解冻钥匙
     */
    @Override
    public void onJieDong(String uid, String to_uid, String lock_id,
                          String key_id) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(jiedong_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(jiedong_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);

                    }
                });
        key.onJieDong(uid, to_uid, lock_id, key_id);
    }

    //重置键盘密码
    @Override
    public void onJianPanPass(String uid, String lock_id, String pwd_info,
                              String timestamp) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(jianpanPass_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(jianpanPass_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);

                    }
                });
        key.onJianPanPass(uid, lock_id, pwd_info, timestamp);
    }

    /**
     * 发送键盘密码
     */
    @Override
    public void onKeyboardPwd(String uid, String lock_id, String pwd_type,
                              String to_phone, String start, String end, String date) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(sendJianPanPass_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(sendJianPanPass_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);

                    }
                });
        key.onKeyboardPwd(uid, lock_id, pwd_type, to_phone, start, end, date);

    }

    /**
     * 判断是否注册白马锁
     */
    @Override
    public void onJudge(String uid) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(isregSitri_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(isregSitri_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        key.onJudge(uid);
    }

    /**
     * 注册白马锁
     */
    @Override
    public void regSitri(String uid) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(regSitri_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(regSitri_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        key.regSitri(uid);
    }

    /**
     * 锁初始化-白马锁（绑定到服务器）
     */
    @Override
    public void initSitri(String uid, String lockMac, String lockName, String lockAlias, String app_time, String pwdInfo) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(initSitri_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(initSitri_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        key.initSitri(uid, lockMac, lockName, lockAlias, app_time, pwdInfo);
    }

    /**
     * 获取租户信息--发送钥匙的时候用到。当该用户的这把锁绑定了房源，获取到该客户的信息
     */
    @Override
    public void onRentInfo(String uid, String lock_id) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(rentInfo_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(rentInfo_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        key.onRentInfo(uid, lock_id);
    }

    /**
     * 上传锁电量
     */
    @Override
    public void onSetPower(String uid, String lock_id, int power) {
        KeyTwoInterface<HouseBean> key = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(setPower_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(setPower_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        key.onSetPower(uid, lock_id, power);
    }

    @Override
    public void onUploadHistoryOfUnlock(String uid, String lockId, final String records, String success, int power) {
        // TODO Auto-generated method stub
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(uploadjilu_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(uploadjilu_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onUploadHistoryOfUnlock(uid, lockId, records, success,power);
    }
    @Override
    public void onUploadHistoryOfUnlockTwo(String uid, String lockId, final String records, String success,String reset_rent_pass, int power) {
        // TODO Auto-generated method stub
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(uploadjilu_two_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(uploadjilu_two_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onUploadHistoryOfUnlockTwo(uid, lockId, records, success,reset_rent_pass,power);
    }
    /**
     * 查询我的钥匙
     */
    @Override
    public void onMyKey(String uid, String kword) {
        // TODO Auto-generated method stub
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(myKey_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(myKey_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onMyKey(uid, kword);
    }
    /**
     * 修改钥匙名字
     */
    @Override
    public void onUpdateKey(String uid, String lockId, String alias) {
        // TODO Auto-generated method stub
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(updateKey_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(updateKey_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onUpdateKey(uid, lockId, alias);
    }
    /**
     * 发送钥匙
     * @param send_type	钥匙类型8.0 说明里面的钥匙类型 管理员发送(1用户/2租户),租户发送(3租户用户)]
     */
    @Override
    public void onSendKey(String uid, String toUid, String lockId, String send_type, String start,
                          String end, String mark) {
        // TODO Auto-generated method stub
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(sendKey_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(sendKey_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onSendKey(uid, toUid, lockId, send_type, start, end, mark);
    }
    /**
     * 锁的钥匙列表
     */
    @Override
    public void onKeyOfLock(String uid, String lockId) {
        // TODO Auto-generated method stub
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(keyOfLock_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(keyOfLock_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onKeyOfLock(uid, lockId);
    }
    /**
     * 键盘密码记录
     */
    @Override
    public void onPassJiLu(String uid, String lock_id, String current_page, String per_page) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(pass_jilu_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(pass_jilu_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onPassJiLu(uid, lock_id,current_page,per_page);
    }
    /**
     * 解绑管理员
     */
    @Override
    public void onUnbindLock(String uid, String lockId, String key_id,String auth_out) {
        // TODO Auto-generated method stub
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(unbindAdmin_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(unbindAdmin_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onUnbindLock(uid, lockId,key_id,auth_out);
    }

    /**
     * 锁推送开关
     * @param push  [0(d)=>不推送，1=>推送]
     */
    @Override
    public void onTuiSong(String uid, String lock_id, int push) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(tuisong_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(tuisong_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onTuiSong(uid, lock_id,push);
    }
    /**
     * 密码添加前置
     */
    @Override
    public void onQianZhi(String uid, String lock_id) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(qianzhi_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(qianzhi_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onQianZhi(uid, lock_id);
    }
    /**
     * 密码删除
     */
    @Override
    public void onDeletePass(String uid, String lock_id, String keyboard_id) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(delete_pass_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(delete_pass_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onDeletePass(uid, lock_id,keyboard_id);
    }

    /**
     * 密码修改
     * @param uid
     * @param lock_id
     * @param keyboard_id   ,密码位id
     * @param pwd           密码值
     * @param start
     * @param end
     */
    @Override
    public void onModifyPass(String uid, String lock_id, String keyboard_id, String pwd, String start, String end) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(modify_pass_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(modify_pass_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onModifyPass(uid, lock_id,keyboard_id,pwd,start,end);
    }

    /**
     * 密码添加回调
     * @param uid
     * @param lock_id
     * @param pwd_list   ,密码列表json
     * @param pwd           密码值
     * @param start
     * @param end
     */
    @Override
    public void onAddPass(String uid,String lock_id,String pwd_list,String app_time,String start,String end,String pwd) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(add_pass_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(add_pass_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onAddPass(uid, lock_id,pwd_list,app_time,start,end,pwd);
    }

    /**
     * 密码别名
     */
    @Override
    public void onModifyAlias(String uid, String lock_id, String keyboard_id, String alias) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(modify_alias_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(modify_alias_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onModifyAlias(uid, lock_id,keyboard_id,alias);
    }
    /**
     * 钥匙别名
     */
    @Override
    public void onEditkey(String uid, String key_id, String mark) {
        KeyTwoInterface<HouseBean> user = new KeyTwoRepository(
                new ICompleteListener() {
                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(key_alias_success);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(key_alias_fail);
                        KeyTwoPresenter.this.setChanged();
                        KeyTwoPresenter.this.notifyObservers(result);
                    }
                });
        user.onEditkey(uid, key_id,mark);
    }

}
